//Doing the Flutterbot Dance.c
#include <avr/io.h>
#include <util/delay.h>
#include <avr/stdio.h>  	//Newly used 
#include <avr/stdlib.h>		//Newly used			
int main (void)


{
	
	DDRD = 0xFF;		 //Set Port D for Output
	PORTD = 0;			//Turn both Motors Off
	DDRB = 0xFF;		//Set Port B for Output
	PORTB = 0;			//Turn off LED's
	while(1)			//creates the famous infinite loop
	
	
	
	{for (int i = 1; i <= 10; i = i + 1)		//Pause to let
	{											//you get your 
		_delay_loop_2(30000);					//hand out of the way
	}	
	
	 PORTD = 0;			//Both Motors still off	
	 PORTB = 1;			//One LED On
		
	for (int i = 1; i <= 20; i = i + 1)
	{	
		srand(700);  		//seeds from this number for the random generator
		int doit;   		//creates an interger called doit
		int doit2;  		//creates an interger called doit2
		doit = rand();		//defines doit as a random number
		doit2 = rand()*3;	//defines doit2 as a different random number
		PORTD = 3;
		_delay_loop_2(doit); 	//Both Motors on as the random number doit 
		PORTD = 1;
		_delay_loop_2(doit2); 	//turns opposite Motor on as the number doit2 
		
	}
	PORTD = 0;					//Stop both motors flutterbot will coast slightly
	PORTB = 0;					//Turn off 1st LED
	PORTB = 2;					//Turn on 2nd LED
	for (int i =1; i <= 20; i = i + 1)
	{
		srand(1200);
		int doit;
		int doit2;
		doit = rand();
		doit2 = rand()*2;
		PORTD = 3;
		_delay_loop_2(doit);
		PORTD = 2;
		_delay_loop_2(doit2);  //opposite Motor on 
		
	}
	}
	PORTD = 0;		//Motors Off
	PORTB = 0;		//Leds Off
	
}
